package com.jxwifi.cloud.quickclean.popwindow;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.idroid.utils.NoDoubleClickListener;
import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.adapter.BuyToolKitAdapter;
import com.jxwifi.cloud.quickclean.adapter.PopAreaAdapter;
import com.jxwifi.cloud.quickclean.adapter.PopKTListAdapter;
import com.jxwifi.cloud.quickclean.bean.ProductsBena;
import com.popwindow.BasicPopmodule;

import java.util.List;

public class KTPopListModule extends BasicPopmodule {


    private List<ProductsBena> mTagsBean;
    //private PopAreaAdapter mAdapter;
    private PopKTListAdapter mAdapter;


    public KTPopListModule(Context ctx, List<ProductsBena> mTagsBean) {
        mContext = ctx;
        this.mTagsBean = mTagsBean;
        initView();
    }

    @Override
    public void setPopwindow(PopupWindow pop) {
        mPopwindows = pop;
    }

    @Override
    public View getView() {
        return mContentView;
    }

    private void initView() {
        mContentView = LayoutInflater.from(mContext).inflate(R.layout.pop_kt_list_module, new LinearLayout(mContext), false);
        setListener();
    }

    private void setListener() {
        View mVwPopBlan = (View) mContentView.findViewById(R.id.vw_pop_blank);
        TextView mTvPopKtNumber=(TextView)mContentView.findViewById(R.id.tv_pop_kt_number);
        RecyclerView mRvPopPreferModule = (RecyclerView) mContentView.findViewById(R.id.rv_pop_kt_list);
        mVwPopBlan.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPopwindows.dismiss();
            }
        });
        mTvPopKtNumber.setText("共"+mTagsBean.size()+"件");

        mRvPopPreferModule.setLayoutManager(new LinearLayoutManager(mContext));
        mRvPopPreferModule.setAdapter(mAdapter = new PopKTListAdapter(R.layout.list_pop_kit_item,mTagsBean));
        mAdapter.openLoadAnimation();
        mAdapter.openLoadAnimation(BaseQuickAdapter.FOOTER_VIEW);

        /*View mVwPopBlan = (View) mContentView.findViewById(R.id.vw_pop_blank);
        TextView mTvPopRecordCancel = (TextView) mContentView.findViewById(R.id.tv_pop_area_cancel);
        RecyclerView mRvPopPreferModule = (RecyclerView) mContentView.findViewById(R.id.rv_pop_area_list);
        mRvPopPreferModule.setLayoutManager(new GridLayoutManager(mContext, 2));
        mRvPopPreferModule.setAdapter(mAdapter = new PopAreaAdapter(R.layout.pop_area_list_item,mAreaindex));
        mAdapter.setNewData(mTagsBean);
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                poplistener.AreaClickTv(position);
                mPopwindows.dismiss();
            }
        });
        mVwPopBlan.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPopwindows.dismiss();
            }
        });
        mTvPopRecordCancel.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPopwindows.dismiss();
            }
        });*/
    }

}
